package cn.how2go.api.mapper;

import cn.how2go.api.common.WarningCount;
import cn.how2go.api.entity.UserWarnning;
import cn.how2go.api.entity.Warning;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author LGP
 * @since 2020-05-31
 */
public interface WarningMapper extends BaseMapper<Warning> {
    @Select("select type,count(1) as shu from warning where state=0 group by type")
    List<WarningCount> countByType();

    @Select("select a.id,a.type,a.recordTime,a.Owner as ownerid,a.state,a.processTime, b.name as onwername from warning as a ,person as b where a.Owner=b.id and (a.state=1 or a.state=2) order by a.RecordTime desc")
    List<UserWarnning> getListUserWarinning();

    @Select("select a.id,a.type,a.recordTime,a.Owner as ownerid,a.state,a.processTime, b.name as onwername from warning as a ,person as b where a.Owner=b.id and a.state=0 order by a.RecordTime desc")
    List<UserWarnning> getNewListUserWarinning();
}
